package com.fxpc.hddc.economyloss.jpa.dao.pg;


import com.fxpc.hddc.economyloss.dto.pg.entity.FxEconomicLossLevelMapPgEntity;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

@Repository
public interface FxEconomicLossLevelMapPgBaseDao extends JpaRepository<FxEconomicLossLevelMapPgEntity, String> {

    @Query(nativeQuery = true, value = "select * from fx_economic_loss_level_map WHERE CAST(create_time AS  DATE)= DATE(:nowDay) AND is_valid='1'  AND extend10= :extend10 ")
    List<FxEconomicLossLevelMapPgEntity> findPgOneDayDataByCreateTime(@Param(value = "nowDay") LocalDate nowDay,@Param(value = "extend10")String extend10);

    @Query(nativeQuery = true, value = "select * from fx_economic_loss_level_map WHERE is_valid='1'  AND extend10= :extend10 ")
    List<FxEconomicLossLevelMapPgEntity> findAllTime(@Param(value = "extend10")String extend10);

    Long count(Specification<FxEconomicLossLevelMapPgEntity> specification);
}
